import java.util.Scanner;

public class sumOfone {
    //相与:同1为1
    public static int xiangYu(int data)
    {
        int count = 0;
        /*for(int i = 0;i < 32;i++)
        {
            if((data & 1) == 1)
                count++;
            data = data >> 1;
        }*/
        for(int i = 0;i < 32;i++)
        {
            if((data & (1 << i)) != 0) //得到相与后的数，而不单单是1
                count++;
        }
        return count;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数：");
        int data = sc.nextInt();
        System.out.println(data + "二进制位的有" + xiangYu(data) + "个1");
    }
}
